package ink.xiaobaibai.valited;

import ink.xiaobaibai.enumOxy.DeviceStatus;
import ink.xiaobaibai.parameterValid.ParameterResult;
import ink.xiaobaibai.parameterValid.ParameterValid;

/**
 * @description:
 * @author: 小白白
 * @create: 2021-05-23
 **/

public class DeviceStatusValueConstraint implements ParameterValid<String, DeviceStatusValid> {

    @Override
    public ParameterResult valid(String s, DeviceStatusValid deviceStatusValid) {
        if (s == null) {
            return ParameterResult.ok();
        }
        for (DeviceStatus deviceStatus : DeviceStatus.values()) {
            if (deviceStatus.getStatus().equals(s)) {
                return ParameterResult.ok();
            }
        }
        return ParameterResult.fair(deviceStatusValid.message());
    }

}
